package util;

import entity.User;

public class UserSessionManager {
    private static UserSessionManager instance;
    private User currentUser;

    private UserSessionManager() {}//私有构造方法，让外部类无法直接通过new关键字创建UserSessionManager类的实例，实现单例模式

    public static UserSessionManager getInstance() {
        if (instance == null) {
            instance = new UserSessionManager();
        }
        return instance;
    }

    public void setCurrentUser(User user) {
        this.currentUser = user;
    }//设置当前用户信息

    public User getCurrentUser() {
        return currentUser;
    }//获取当前用户信息

    public void logout() {
        currentUser = null;
    }
}